import request from "@/utils/request";
import { file } from "@/api/file/index";
export const apis = {
  add: (data) => {
    return request({
      url: "/preventionHiddenRegister/create",
      method: "post",
      data: data,
    });
  },

  query: (params) => {
    return request({
      url: "/preventionHiddenRegister/list",
      method: "get",
      params,
    });
  },
  querydj: (params) => {
    return request({
      url: "/preventionHiddenRegister/listdj",
      method: "get",
      params,
    });
  },
  queryzg: (params) => {
    return request({
      url: "/preventionHiddenRegister/listzg",
      method: "get",
      params,
    });
  },
  queryAll: (params) => {
    return request({
      url: "/preventionHiddenRegister/listAll",
      method: "get",
      params,
    });
  },
  del: (row) => {
	if(row.hiddenFrom && row.hiddenFrom=='1') {
		return request({
		  url: "/check/governHiddenInventory",
		  method: "put",
		  data: {
			  hiddenInventoryId: row.hiddenId,
			  governDeleted: 1
		   },
		}).then((res) => {
		  if (row.hiddenImageFileId) {
		    file.del(row.hiddenImageFileId);
		  }
		  return res;
		});
	} else {
		return request({
		  url: "/preventionHiddenRegister/delete",
		  method: "get",
		  params: {
		    id: row.hiddenId,
		  },
		}).then((res) => {
		  if (row.hiddenImageFileId) {
		    file.del(row.hiddenImageFileId);
		  }
		  return res;
		});
	}
  },
  update: (data) => {
	if (data.hiddenFrom && data.hiddenFrom=='1') {
		return request({
		  url: "/check/governHiddenInventory",
		  method: "put",
		  data: data,
		});
	} else {
		return request({
		  url: "/preventionHiddenRegister/update",
		  method: "post",
		  data: data,
		});		
	}
  },
  
  // 审核接口
  updateHiddenState: (data) => {
    return request({
      url: "/preventionHiddenRegister/updateHiddenState",
      method: "post",
      data: data,
    });
  },
  
  // 审核接口
  updateHiddenState2: (data) => {
    return request({
      url: "/check/governHiddenInventory/confirm",
      method: "post",
      data: data,
    });
  },
  
  // 流转接口
  updateRectificationUserName: (data) => {
    return request({
      url: "/preventionHiddenRegister/updateRectificationUserName",
      method: "post",
      data: data,
    });
  },
  // 流转接口
  updateRectificationUserName2: (data) => {
    return request({
      url: "/check/governHiddenInventory",
      method: "put",
      data: data,
    });
  },
  
  zz: (params) => {
    return request({
      url: "preventionDevice/list",
      method: "get",
      params,
    });
  },
  // exportQd: (data) => {
  //   return request({
  //     url: "/preventionHiddenRegister/export",
  //     method: "post",
  //     data: data,
  //   });
  // },
  url: "/preventionHiddenRegister/",
};
